package com.sc.nft.dao;

import lombok.extern.slf4j.Slf4j;
import com.sc.nft.entity.UserMarketValue;
import com.sc.nft.mapper.UserMarketValueMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.List;

/**
 * 用户市值表(sc_user_market_value)数据DAO
 *
 * @author zxy
 * @description 用户市值
 * @since 2023-07-21 00:27:15
 */
@Slf4j
@Repository
public class UserMarketValueDao extends ServiceImpl<UserMarketValueMapper, UserMarketValue> {

    /**
     * 清空表
     */
    public void truncate() {
        try{
            baseMapper.history();
        }catch (Exception e){
            log.warn("record market value error,",e);
        }
        baseMapper.truncate();
    }


    /**
     * 清空表
     */
    public void init() {
        baseMapper.init();
    }

    public BigDecimal getMarketValue(Long userId, List<Long> expectUserId) {
        return baseMapper.getMarketValue(userId, expectUserId);
    }

    /**
     * 获取用户的团队熔炼的持仓成本
     *
     * @param userId
     * @param day
     * @param urbanServiceCenter
     * @return
     */
    public BigDecimal getTheTotalPerformanceOfTheUserTeam(Long userId, Integer day, Boolean urbanServiceCenter) {
        return baseMapper.getTheTotalPerformanceOfTheUserTeam(userId, day, urbanServiceCenter);
    }

    /**
     * 获取用户在熔炼中的持仓成本
     *
     * @param userId
     * @return
     */
    public BigDecimal getUserSmeltCost(Long userId) {
        return baseMapper.getUserSmeltCost(userId);
    }
    public BigDecimal getEcologyMarketValue(Long userId, List<Long> expectUserId) {
        return baseMapper.getEcologyMarketValue(userId, expectUserId);
    }


    /**
     * 获取用户持仓金额大于多少的用户数量
     * @param userIds
     * @return
     */
    public Integer getUserIdsPositionCount(List<Long> userIds,BigDecimal position) {
        return baseMapper.getUserIdsCount(userIds,position);
    }

    /**
     * 团队藏品持仓总额
     * @param userIds
     * @return
     */
    public BigDecimal getUserIdsYesterdayMarketValue(List<Long> userIds) {
        return baseMapper.getUserIdsYesterdayMarketValue(userIds);
    }

    /**
     * 团队生态熔炼市值总额
     * @param userIds
     * @return
     */
    public BigDecimal getUserIdsSmeltMarketValue(List<Long> userIds) {
        return baseMapper.getUserIdsSmeltMarketValue(userIds);
    }
}